package com.gradle.quartz.batch.valid;

import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.JobParametersValidator;
import org.springframework.util.StringUtils;

/**
 * name参数校验，name=null 或者 name="" 抛出异常
 * @author ldanniel
 */
public class NameParamValidator implements JobParametersValidator {
    @Override
    public void validate(JobParameters parameters) throws JobParametersInvalidException {
        String name = parameters.getString("name");
        if (StringUtils.hasText(name)){
            throw new JobParametersInvalidException("name 不能为空");
        }
    }
}
